﻿using DevExpress.XtraEditors;
using DXApplicationTangche.UC.生产计划.编排生产批.service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.生产计划.编排生产批
{
    public partial class Form成衣在制品记录 : DevExpress.XtraEditors.XtraForm
    {
        public Form成衣在制品记录()
        {
            InitializeComponent();
            this.刷新();
        }

        private void 刷新()
        {
            List<BarcodeWipRecordDTO> barcodeWipRecordDTOs = 编排生产批Service.getBarcodeLogList();
            this.gridControl成衣在制品记录.DataSource = barcodeWipRecordDTOs;
            this.gridView成衣在制品记录.RefreshData();
        }

        private void 同步()
        {
            this.splashScreenManager.ShowWaitForm();
            this.splashScreenManager.SetWaitFormCaption("请稍后,正在加载中...."); // 标题
            this.splashScreenManager.SetWaitFormDescription("正在初始化....."); // 信息
            //  同步数据并刷新
            编排生产批Service.barcodeLogSync(DateTime.Now.ToString("yyyy-MM-dd"));
            this.刷新();
            this.splashScreenManager.CloseWaitForm();
        }

        private void simpleButton同步数据并刷新_Click(object sender, EventArgs e)
        {
            this.同步();
        }

        private void simpleButton导出excel_Click(object sender, EventArgs e)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();
            fileDialog.Title = "导出Excel";
            fileDialog.Filter = "Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = fileDialog.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                this.gridControl成衣在制品记录.ExportToXls(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void gridView成衣在制品记录_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            try
            {
                if (e.Column.Name == "gridColumn半成品检查" 
                    || e.Column.Name == "gridColumn钉锁"
                    || e.Column.Name == "gridColumn手缝"
                    || e.Column.Name == "gridColumn成品检查"
                    )
                {
                    if ("0001/1/1".Equals(e.DisplayText))
                    {
                        e.Appearance.BackColor = Color.LightPink;
                    }
                }
            }
            catch  { }
        }

    }
}